home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: SendThorMail.rexx 2.1 (15.9.99) Neil Bothwick
- A Thor script to create a Thor email event
- This is a modified version for use with OpenURL
- */
-
- /* ;;; Initialise */
- options results
- if ~show('p', 'BBSREAD') then do
- address command
- 'run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead'
- 'WaitForPort BBSREAD'
- end
- CDF_MAIL = '00000002'x /* Private mail conference. */
- CDB_MAIL = 1 /* Private mail conference. */
- ;;;
- /* ;;; Read arguments */
- parse arg arguments
- template = 'SYSTEM/K,CONF/K,ADDRESS/A/K,NAME/K,SUBJECT/K,TEXT/K,CC/K,BCC/K,ATTACH/K'
- drop ARGS.
- ARGS.SUBJECT= ' '
- ARGS.TEXT = 'STDIN'
- address(BBSREAD)
- READARGS template ARGS CMDLINE arguments
- if RC = 5 then call ExitMsg('Usage: SendThorMail.rexx' template)
- ;;;
- /* ;;; Get System and Conference if not given on command line */
- if symbol('ARGS.SYSTEM') ~= 'VAR' then do
- drop Systems.
- 'GETBBSLIST stem SYSTEMS'
-
- do i = 1 to Systems.COUNT
- SystemName = Systems.i
- drop SysData.
- 'GETBBSDATA bbsname "'Systems.i'" stem SYSDATA'
- if left(SysData.BBSTYPE,3) = 'TCP' then do
- ARGS.SYSTEM = Systems.i
- leave
- end
- end
- end
-
- call CheckSystem()
- if symbol('ARGS.CONF') ~= 'VAR' then ARGS.CONF = 'Email'
- ;;;
-
- /* ;;; Create message file */
- address(BBSREAD)
- drop SysInfo.
- GETBBSDATA bbsname '"'ARGS.SYSTEM'"' stem SysInfo
-
- UNIQUEMSGFILE bbsname '"'ARGS.SYSTEM'"' stem MsgFile
- if ~open(out,MsgFile.NAME,'w') then call ExitMsg('Unable to create message file')
- if symbol('ARGS.CC') = VAR then call writeln(out,'cc:' ARGS.CC)
- if symbol('ARGS.BCC') = VAR then call writeln(out,'bcc:' ARGS.BCC)
-
- /* Add contents of .header */
- if exists(SysInfo.BBSPATH||'.header') then do
- if ~open(hdr,SysInfo.BBSPATH||'.header','r') then call ExitMsg('Could not open header file')
- do until eof(hdr)
- call writeln(out,readln(hdr))
- end
- call close(hdr)
- end
- else if symbol('ARGS.CC') = VAR | symbol('ARGS.BCC') = VAR then call writeln(out,'')
-
- /* Copy from text to message file */
- if ARGS.TEXT = 'STDIN' then do
- do until eof('STDIN')
- call writeln(out,compress(readln('STDIN'),'0d'x)) /* Strip superfluous CRs */
- end
- end
- else do
- if ~open(text,ARGS.TEXT,'R') then call ExitMsg('Could not read message text file')
- do until eof(text)
- call writeln(out,compress(readln(text),'0d'x)) /* Strip superfluous CRs */
- end
- call close(text)
- end
- call close(out)
- ;;;
- /* ;;; Create email event */
- drop EventData.
- EventData.TOADDR = ARGS.ADDRESS
- EventData.SUBJECT = ARGS.SUBJECT
- EventData.CONFERENCE = ARGS.CONF
- EventData.MSGFILE = MsgFile.FILEPART
- if symbol('ARGS.NAME') = VAR then EventData.TONAME = ARGS.NAME
- if symbol('ARGS.ATTACH') = VAR then EventData.LOCALFILE = ARGS.ATTACH
-
- WRITEBREVENT bbsname '"'ARGS.SYSTEM'"' event 0 stem EventData
- if(rc ~= 0) then call ExitMsg(BBSREAD.LASTERROR)
- ;;;
-
- exit
-
- /* ;;; Exit with a message */
- ExitMsg:
- parse arg msg
- if msg > '' then do
- address command 'RequestChoice >NIL: "SendThorMail.rexx" "'msg'" "OK"'
- /*say;say msg;say*/
- exit 5
- else exit
- return
- ;;;
- /* ;;; Check that the system and conference are valid */
- CheckSystem:
- drop SysData.
- 'GETBBSDATA bbsname "'ARGS.SYSTEM'" stem SYSDATA'
- if RC > 0 then call ExitMsg('You must specify the name of an Internet system')
- if left(SysData.BBSTYPE,3) ~= 'TCP' then call ExitMsg('You must specify the name of an Internet system')
-
- drop ConfData.
- 'GETCONFDATA bbsname "'ARGS.SYSTEM'" confname "'ARGS.CONF'" stem CONFDATA'
- if bittst(ConfData.FLAGS,CDB_MAIL) = 0 then call ExitMsg('You must specify the name of an Email conference')
- return
- ;;;
-
-